var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2PlatformMgr = require("PlatformMgr");
var $2BaseUIPopup = require("BaseUIPopup");
var $2GameUser = require("GameUser");
var $2AudioManager = require("AudioManager");
var $2UIManager = require("UIManager");
var $2GameConfig = require("GameConfig");
var $2levelconfig = require("levelconfig");
var $2UIVMain = require("UIVMain");
var $2UIHelp = require("UIHelp");
var $2Platformconf = require("Platformconf");
var $2ServerConfig = require("ServerConfig");
var $2MiniPlatform = require("MiniPlatform");
var $2Globe = require("Globe");
var $2EventCenter = require("EventCenter");
var $2EventDefine = require("EventDefine");
var $2RankMgr = require("RankMgr");
var $2constant = require("constant");
var $2gameBefore = require("gameBefore");
var $2UIPrank = require("UIPrank");
var $2UIPskin = require("UIPskin");
var $2UIPtili = require("UIPtili");
var $2ConstValue = require("ConstValue");
var $2NodeManager = require("NodeManager");
var A;
(function (e) {
  e[e.btn_Home = 0] = "btn_Home";
  e[e.btn_Share = 1] = "btn_Share";
  e[e.btn_next = 2] = "btn_next";
  e[e.fail = 3] = "fail";
  e[e.win = 4] = "win";
  e[e.btn_rank = 5] = "btn_rank";
  e[e.btn_tryagain = 6] = "btn_tryagain";
  e[e.max = 7] = "max";
})(A || (A = {}));
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_UIPEnd = /* */function (_s$default2) {
  function _ctor() {
    var _this109;
    babel_classCallCheck(this, _ctor);
    _this109 = _callSuper(this, _ctor, arguments);
    _this109.ndArrs = [];
    _this109.weijiesuos = [];
    return _this109;
  }
  babel_inherits(_ctor, _s$default2);
  return babel_createClass(_ctor, [{
    key: "setWin",
    value: function setWin(e) {
      if (e) {
        $2AudioManager.AudioManager.getInstance().playSound("guoguan");
        if ("game_2" == $2GameUser.default.getInstance().currlevelName) {
          $2GameUser.default.getInstance().PassLevelNum++;
          $2GameUser.default.getInstance().PassLevelNum_day++;
          $2GameUser.default.getInstance().PassLevelNum_week++;
          $2GameUser.default.getInstance().PassLevelNum_month++;
          var _e58 = $2GameUser.default.getInstance().PassLevelNum_day;
          var _t58 = $2GameUser.default.getInstance().PassLevelNum_week;
          var _n53 = $2GameUser.default.getInstance().PassLevelNum_month;
          $2RankMgr.RankMgr.instance.putScore($2constant.RANKTYPE.day, _e58);
          $2RankMgr.RankMgr.instance.putScore($2constant.RANKTYPE.week, _t58);
          $2RankMgr.RankMgr.instance.putScore($2constant.RANKTYPE.month, _n53);
          console.log("今日通关数：game_2", _e58, _t58, _n53);
        } else if ("game_3" == $2GameUser.default.getInstance().currlevelName) {
          $2GameUser.default.getInstance().PassLevelNum_yjwj++;
          $2GameUser.default.getInstance().PassLevelNum_day_yjwj++;
          $2GameUser.default.getInstance().PassLevelNum_week_yjwj++;
          $2GameUser.default.getInstance().PassLevelNum_month_yjwj++;
          var _e59 = $2GameUser.default.getInstance().PassLevelNum_day_yjwj;
          var _t59 = $2GameUser.default.getInstance().PassLevelNum_week_yjwj;
          var _n54 = $2GameUser.default.getInstance().PassLevelNum_month_yjwj;
          $2RankMgr.RankMgr.instance.putScore($2constant.RANKTYPE.day_yjwj, _e59);
          $2RankMgr.RankMgr.instance.putScore($2constant.RANKTYPE.week_yjwj, _t59);
          $2RankMgr.RankMgr.instance.putScore($2constant.RANKTYPE.month_yjwj, _n54);
          console.log("今日通关数：game_3", _e59, _t59, _n54);
        }
      }
      this.ndArrs[A.win].active = e;
      this.ndArrs[A.fail].active = !e;
      this.ndArrs[A.btn_Share].active = e;
      this.ndArrs[A.btn_next].active = e;
      this.ndArrs[A.btn_rank].active = !e;
      this.ndArrs[A.btn_tryagain].active = !e;
    }
  }, {
    key: "setResult",
    value: function setResult(e) {
      this.setWin(1 == e.win);
      console.log("setResult");
    }
  }, {
    key: "onShow",
    value: function onShow() {
      var _this110 = this;
      babel_get(babel_getPrototypeOf(_ctor.prototype), "onShow", this).call(this);
      $2NodeManager.default.Instance.openTiliView();
      $2EventCenter.default.regisEvent($2EventDefine.default.EVENT_ONSHOW, this.onGameShow, this);
      $2MiniPlatform.default.Instance.recorderStop();
      this.content.opacity = 0;
      this.node.pauseSystemEvents(true);
      cc.tween(this.content).to(.8, {
        opacity: 255
      }).call(function () {
        _this110.node.resumeSystemEvents(true);
      }).start();
      !$2GameUser.default.getInstance().isFreeTwoHourCD && $2ServerConfig.default.getInstance().gameconfig.config.isHadRenWu1 && $2GameUser.default.getInstance().gameOverNum++;
      $2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.WXGame && cc.Canvas.instance.node.getComponent($2gameBefore.default).BannerShow();
      if ($2ConstValue.ConstValue.PlayerOnLineTime >= 60) {
        if ($2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.TTGame) {
          if ($2ConstValue.ConstValue.InterAdIntervalTime <= 0) {
            console.log("-------------------开始调用插屏广告------------------"), $2PlatformMgr.default.Instance().interstitialShow(0);
          }
        } else {
          $2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.KWaiGame && $2ConstValue.ConstValue.InterAdIntervalTime <= 0 && $2PlatformMgr.default.Instance().interstitialShow(0);
        }
      }
      $2Platformconf.default.PlatformType === $2Platformconf.ePlatformType.WXGame && $2PlatformMgr.default.Instance().interstitialShow(0);
      null != $2UIManager.UIManager.getInstance().getUI($2UIVMain.default) && $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).hideYXQ();
    }
  }, {
    key: "compareVersions",
    value: function compareVersions(e, t) {
      var n = e.split(".").map(Number);
      var o = t.split(".").map(Number);
      for (var _i28 = 0; _i28 < Math.max(n.length, o.length); _i28++) {
        var _e60 = n[_i28] || 0;
        var _t60 = o[_i28] || 0;
        if (_e60 < _t60) {
          return -1;
        }
        if (_e60 > _t60) {
          return 1;
        }
      }
      return 0;
    }
  }, {
    key: "click",
    value: function click(e, t) {
      babel_get(babel_getPrototypeOf(_ctor.prototype), "click", this).call(this, e, t);
      if ("Home" == t) {
        this.close();
        $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).mapNode.removeAllChildren();
        $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).setContent(true);
        $2UIManager.UIManager.getInstance().showUI($2UIPskin.default);
        null != $2UIManager.UIManager.getInstance().getUI($2UIVMain.default) && $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).showYXQ();
        $2ConstValue.ConstValue.IsGaming = false;
        $2NodeManager.default.Instance.openTiliView();
      } else if ("repaly" == t) {
        if ($2GameUser.default.getInstance().tili >= 1) {
          $2GameUser.default.getInstance().tili -= 1;
          $2EventCenter.default.postEvent($2EventDefine.default.GAME_TILI_INFO_UPDATE);
          $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).initGame();
          $2NodeManager.default.Instance.closeTiliView();
          this.close();
        } else {
          $2UIManager.UIManager.getInstance().showUI($2UIPtili.default);
        }
      } else if ("next" == t) {
        if ($2GameUser.default.getInstance().tili >= 1) {
          $2GameUser.default.getInstance().tili -= 1;
          $2EventCenter.default.postEvent($2EventDefine.default.GAME_TILI_INFO_UPDATE);
          $2UIManager.UIManager.getInstance().getUI($2UIVMain.default).initGame();
          $2NodeManager.default.Instance.closeTiliView();
          this.close();
        } else {
          $2UIManager.UIManager.getInstance().showUI($2UIPtili.default);
        }
      } else if ("share" == t) {
        $2MiniPlatform.default.Instance.shareAppMessage(function (e) {
          if (true === e) {
            console.log("分享成功");
            $2UIHelp.UIHelp.showTip("分享成功");
          }
        }, {
          videoTag: $2GameUser.default.getInstance().currlevelName
        });
      } else {
        "rank" == t && $2UIManager.UIManager.getInstance().showUI($2UIPrank.default);
      }
    }
  }, {
    key: "onGameShow",
    value: function onGameShow(e) {
      if ($2Platformconf.default.PlatformType == $2Platformconf.ePlatformType.TTGame) {
        window.tt.getAppInfoSync();
        console.log("launchFrom:", e.launch_from);
        console.log("location:", e.location);
        console.log("res:", e);
      }
    }
  }, {
    key: "unlockRandom",
    value: function unlockRandom() {
      var e = $2GameConfig.default.getInstance().getConfig($2levelconfig.default).getLevelsByLevelsType($2GameUser.default.getInstance().curlevelType);
      for (var _t61 = 0; _t61 < e.length; _t61++) {
        var _n55 = e[_t61];
        $2GameUser.default.getInstance().getUnlockLevel(_n55.prefabName) || (this.weijiesuos[this.weijiesuos.length] = _t61);
      }
      if (this.weijiesuos.length > 0) {
        var _t62 = $2Globe.default.getInstance().random(0, this.weijiesuos.length - 1);
        $2GameUser.default.getInstance().setUnlockLevel(e[this.weijiesuos[_t62]].prefabName, true);
        $2UIHelp.UIHelp.showTip("已解锁关卡:" + e[this.weijiesuos[_t62]].titletext);
      }
    }
  }]);
}($2BaseUIPopup.default);
def_UIPEnd.className = "UIPEnd";
cc__decorate([ccp_property(Array(cc.Node))], def_UIPEnd.prototype, "ndArrs", undefined);
def_UIPEnd = cc__decorate([ccp_ccclass], def_UIPEnd);
exports.default = def_UIPEnd;